require 'prawn'
require 'prawn/table'
# load customised tilt/prawn (for 2.0 compatibility and support for :page_size settings)
# require_relative '../lib/tilt/prawn'
require_relative 'lib/prawn/my_helpers'
require 'date'

timestamp = Time.now.strftime("%Y%m%d%H%M%S")

# include my formatters/helpers
::Prawn::Document.extensions << Prawn::MyHelpers
# template = Tilt.new("views/base-document.prawn", :page_size => "A4", :page_layout => :portrait )
pdf = Prawn::Document.new
# ensure default fonts are available
pdf.my_default_fonts

# set default font
# pdf.font "Lato"

# add the header and footer on each page
pdf.repeat(:all) do
  # set the header
  pdf.my_logo_header

  # set the footer
  pdf.my_footer_with_address
end

# set the body (content section)
#  -- (sizes based upon A4 format and size of header & footer, adjust as required)
#
pdf.bounding_box([0, 690], :width => 520, :height => 620) do

  # fix the font leading
  pdf.default_leading 1
  pdf.font_size 11

  10.times do

    pdf.text "Lorem ipsum <b>dolor sit amet</b>,...", :inline_format => true
    pdf.move_down 10

    # testing basic table support within the output
    # data = [ ['Key', 'Value'],['1', 'A'],['2','B'],['3','C'],['4','D'],['5','F']]
    # pdf.table(data, :column_widths => [35, 70], :cell_style => { :border_color => 'CCCCCC', :border_width => 1 }) do
    #   row(0).font_style = :bold
    #   row(0).border_bottom_color = '333333'
    # end

    pdf.move_down 20
    pdf.table [["Just <font size='18'>some</font> <b><i>inline</i></b>","",""],["<color rgb='FF00FF'>styles</color> being applied here","",""]],:cell_style =>{:inline_format => tru

    pdf.move_down 20

  end

  # NOTE!! we must set page numbers within the bounding_box() to get them correctly displayed
  pdf.my_page_numbers("- <page> of <total> -")
end

pdf.render_file "test.pdf"
